<cfset BASE = CreateObject("component", "#session.rootDir#.cfc.base") />

<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlHeaderNonSCF(
    "/jquery/ui-1.8.5/jquery-ui.min.js,/jquery/plugins/scrollTo/jquery.scrollTo-1.4.2-min.js,/" & session.rootDir & "/js/nonSCFStep1-Request.js", <!---JS links--->
    "/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css", <!---CSS links--->
    "Contractor Expiration Date Review Master Page", <!---Page Title--->
    "Status", <!---Active Nav Link--->
    "true" <!---Alternate menu.  Shows main EPAR links--->
)#
<!---HTML header, css links, js links, and page title--->


<cfif Session.Auth EQ True and (Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR)>

	<cfobject type="dotnet" name="objQuery" class="ADTools.Query" assembly ="C:\Program Files\Southcentral Foundation\ADTools\ADTools.dll">
	<cfobject type="dotnet" name="objModify" class="ADTools.Modify" assembly ="C:\Program Files\Southcentral Foundation\ADTools\ADTools.dll">
	
	<cfset bolTermReq = False>
	
	<cfif isdefined("Form.Submit")>
		<!--- Check Form for required action --->
		
		<!--- Loop through all form elements and processes selected contractors --->
		<cfloop index="objField" list="#FORM.FieldNames#" DELIMITERS=",">
			
			<cfif left(objField,3) EQ "rdo" And Form[objField] EQ 1>
				<!--- Extend the expiration date for one month --->	
				<cfset strUserID = ListGetAt(right(objField, len(objField)-3),1,"|")>
				<cfset strExpDate = ListGetAt(right(objField, len(objField)-3),2,"|")>	
				
				<!---cfset strNewDate = DateFormat(dateAdd("d",-1,dateAdd("m", 1, strExpDate)), "mm/dd/yyyy")--->
				<cfset strNewDate = BASE.DateFormat(dateAdd("m", 1, strExpDate), "mm/dd/yyyy")>
				  
				<cfset strDN = objQuery.GetProperty("distinguishedName", "10.100.1.101", #strUserID#, "", "")>
				
				<cfset objModify.init("10.100.1.101")>
				<cfset lngResult = objModify.SetAccountExpirationDateCF(#strDN#, "#strNewDate# 1:00:00 AM")>
			
			<cfelseif left(objField,3) EQ "rdo" And Form[objField] EQ 2>
				<!--- Send a termination notice to the service desk --->
				<cfset strUserID = ListGetAt(right(objField, len(objField)-3),1,"|")>
                
				<cfmail to="helpdesk@scf.cc" from="#Session.arrEmpInfo.Email#" cc="#Session.arrEmpInfo.Email#" bcc="bfrick@scf.cc" subject="Archive User Request" type="html">	
					Service Desk,<BR /><BR />				
					Please archive the following account:<BR /><BR />
					#strUserID#<BR /><BR /><br />
					NOTE:  This is an automated message and the mailbox is not monitored.  Please do not reply to this message.
				</cfmail>
				
				<cfset bolTermReq = True>
			</cfif>
			
		</cfloop>		
			
	</cfif>
	
	
	<cfset strDN = "">
	
	<!--- Check first for the employees listed in AD as their direct hires --->    
	
	<cfset lngResult = objQuery.ConnectToLDAP("10.100.1.101")>
	
	<cfquery name = "qryGetContractors" datasource="#Session.DataSourceSCF_General#">
		Select * from SCF.dbo.func_GetUsers(0,1,0)
		Where UserTypeID not in (0, 1, 7) and Login is not null and left(Login, 4) <> 'ANMC'
		Order By LastName
	</cfquery>

		<h1 class="title">Contractor Expiration Date Extension</h1>
		<div class="entry">    
		 Welcome, <strong>#Session.EmpInfo.FullName#</strong>.&nbsp;&nbsp;This 
         is the master page for contractor expiration dates.&nbsp;&nbsp;All 
         contractors at SCF should appear on this page with their manager and 
         expiration dates.&nbsp;&nbsp;Accounts will expire at the end of every 
         month.&nbsp;&nbsp;To extend the operating window for an additional 
         month, select the option in the "Extend" column.&nbsp;&nbsp;There is 
         a two week window prior to the end of each month where this option 
         will be available to you.&nbsp;&nbsp;If the contractor is no longer 
         with SCF, please select the "Terminate" option.&nbsp;&nbsp;<br /><br />       
		
		<cfform name="frmExpiration" method="post">
		<cfinput type="hidden" name="Submit" value="Submission Validation">
		<table align="center">
		<cfset arrContractor = ArrayNew(2)>
		
		<cfif bolTermReq>	
		<tr>
			<td colspan="7">
				<span class="error">Your termination request has been sent to the Service Desk.<BR /></span>
			</td>
		</tr>
		<tr>
			<td>&nbsp; </td>
		</tr>
		</cfif>			
		
		<tr>
			<td>
				<strong>Contractor Name</strong>
			</td>
			<td>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
			<td>
				<strong>Manager Name</strong>
			</td>
			<td>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
			<td>
				<strong>Expiration Date</strong>
			</td>
			<td>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
			<td align="center">
				<strong>Extend</strong>
			</td>
			<td>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
			<td align="center">
				<strong>Terminate*</strong>
			</td>
		</tr>
		
		<cfloop query="qryGetContractors"> 	
			<cfset strExpDate = objQuery.GetAccountExpirationDate(#qryGetContractors.AD_GUID#, "10.100.1.101")>
			<cfset strExpDate = DateFormat(strExpDate, "mm/dd/yyyy")>
			<cfset strManagerDN = objQuery.GetProperty("manager", "10.100.1.101", "","#qryGetContractors.AD_GUID#","")>
			<cfif not isdefined("strManagerDN")>
				<cfset strManagerDN = "">
			</cfif>
			<cfset strManager = objQuery.GetProperty("displayName", "10.100.1.101", "", "", "#strManagerDN#")>
			<cfif not isdefined("strManager")>
				<cfset strManager = "">
			</cfif>
			<cfset strUserID = qryGetContractors.Login>
			<cfset strDisplay = qryGetContractors.LastNameFirst>
			<cfif DateAdd("d", -14, strExpDate) GT Now()>
				<cfset bolNA = False>
			<cfelse>
				<cfset bolNA = True>
			</cfif>
																					
			<tr>
				<td>						
					#strDisplay#
				</td>
				<td>&nbsp;</td>
				<td>
					#strManager#
				</td>
				<td>&nbsp;</td>
				<td>
					#strExpDate#
				</td>
				<td>&nbsp;</td>
				<td align="center">
					<cfif bolNA>
						<cfinput type="radio" name="rdo#strUserID#|#strExpDate#" 
                        value="1">
					<cfelse>
						<span class="error">N/A</span>
					</cfif>
				</td>
				<td>&nbsp;</td>
				<td align="center">
					<cfinput type="radio" name="rdo#strUserID#|#strExpDate#" 
                    value="2">
				</td>
			</tr>
			</tr>
		</cfloop>
		<tr>
			<td>&nbsp;</td>
		</tr>	
		<tr>
			<td colspan="9" align="right">
				<cfinput type="button" name="Clear" value="Clear" 
                    onclick="$(':radio').attr('checked', 'false')">
                <cfinput type="submit" name="Submit" value="Submit">
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>	
		</table>
		</cfform> 
		*NOTE:&nbsp;&nbsp;All termination requests are sent via email to the 
        Service Desk.&nbsp;&nbsp;You will receive a copy of the email, but 
        please allow one business day to complete the request.&nbsp;&nbsp;If 
        immediate action is necessary, please call the Service Desk directly 
        at x5200.
		</div>
		
<cfelse>

	<cfinclude template="../../denied.cfm">

</cfif>

<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlFooterNonSCF()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>

